package com.yang.sms.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Billyang
 * @date 2024/9/26 21:00
 */
public interface SmsTaskDetailEnum {

    @AllArgsConstructor
    enum Status{
        // 1:待发送,2:待定时发送,11:发送MQ成功,12:MQ消费成功,21:请求成功,22:请求失败,31:取消发送
        //过渡态
        WAIT_SEND(1,"待发送"),
        WAIT_PLAN_SEND(2,"待定时发送"),
        SEND_MQ_SUCCESS(11,"发送MQ成功"),
        MQ_CONSUME_SUCCESS(12,"MQ消费成功"),

        //终态
        REQUEST_SUCCESS(21,"请求成功"),
        REQUEST_FAIL(22,"请求失败"),
        CANCEL_SEND(31,"取消发送");
        @Getter
        private Integer code;
        @Getter
        private String desc;

        public static Status of(Integer code) {
            for (Status item : Status.values()) {
                if (item.getCode().equals(code)) {
                    return item;
                }
            }
            return null;
        }
    }
}
